package com.dlc.apk.ui.model

import android.view.View
import androidx.databinding.ObservableField
import androidx.databinding.ObservableInt

class AdForm : BaseModel() {
    val adItems = ObservableField<List<AdItem>>()

    var position: String = AD_TYPE_FULLSCREEN //显示位置： 1 全屏，2 首页
    var content: String = ""

    //大屏默认广告是否显示
    @JvmField
    val fullscreenDefaultAdVisibility: ObservableInt = object : ObservableInt(adItems) {
        override fun get(): Int {
            return if (adItems.get()?.size == 0) {
                View.VISIBLE
            } else View.GONE
        }
    }

    //内屏默认广告是否显示
    @JvmField
    val insideDefaultAdVisibility: ObservableInt = object : ObservableInt(adItems) {
        override fun get(): Int {
            return if (adItems.get()?.size == 0) {
                View.VISIBLE
            } else View.GONE
        }
    }


    companion object {
        val AD_TYPE_FULLSCREEN = "1"
        val AD_TYPE_HOME = "2"

        const val typeImage = "image"
        const val typeVideo = "video"
    }

    data class AdItem(val type: String, val url: String, val duration: Int = 10) {
        var startTime: String = "00:00:00"
        var endTime: String = "23:59:59"

        var startTimestamp: Long = 0
        var endTimestamp: Long = 0

        var adId: String? = ""
    }
}